﻿#region Using
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

using ghrb.Gameplay;
using ghrb.Managers;
#endregion

namespace ghrb.States
{
    /// <summary>
    /// Game state class
    /// </summary>
    class StateGame : State
    {
        #region Public Functions
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="parent">Parent</param>
        public StateGame(Game1 parent)
            : base(parent)
        {
        }

        /// <summary>
        /// Load all the content needed for the game state
        /// </summary>
        /// <param name="content">ContentManager</param>
        public override void LoadContent(ContentManager content)
        {
            //Load highways content
            m_Highway.LoadContent(content, m_Parent.GraphicsDevice.Viewport.AspectRatio);

            //Activate players input
            m_Parent.GetInputManagers[0].StartThread();
        }

        /// <summary>
        /// Update the state
        /// </summary>
        /// <param name="gameTime">Game time</param>
        public override void Update(GameTime gameTime) {
            if (Keyboard.GetState().IsKeyDown(Keys.Up))
                offset += 0.01f;
            if (Keyboard.GetState().IsKeyDown(Keys.Down))
                offset -= 0.01f;
        }

        /// <summary>
        /// Draw the state
        /// </summary>
        public override void Draw()
        {
            //Draw the highway
            m_Highway.Draw(offset);
        }
        #endregion

        #region Properties and Vars
        private Highway m_Highway = new Highway();
        private float offset = 0;
        #endregion
    }
}
